package com.tengju.user.infrastructure.repository.convert;

import com.tengju.user.domain.model.archive.sign.SignFromEnum;
import com.tengju.user.domain.model.archive.sign.SignId;
import com.tengju.user.domain.model.archive.sign.SignRecord;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.SignRecordDO;

public class SignRecordConvert {

    public static SignRecordDO convert(SignRecord signRecord) {
        if(signRecord == null){
            return null;
        }
        SignRecordDO signRecordDO = new SignRecordDO();
        signRecordDO.setSignId(signRecord.getSignId().getValue());
        signRecordDO.setSignFrom(signRecord.getSignFrom().getCode());
        return signRecordDO;
    }

    public static SignRecord convert(SignRecordDO signRecordDO) {
        if(signRecordDO == null){
            return null;
        }
        return new SignRecord(new SignId(signRecordDO.getSignId()),
                SignFromEnum.form(signRecordDO.getSignFrom()));
    }
}
